﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;

namespace CommonClass.PublicClass
{
  


    /// <summary>
    /// CLR版本: 4.0.30319.18444
    /// 命名空间名称: 常用类.PublicClass
    /// 文件名: CommonClass
    /// 创建者：YangHQ
    /// 创建时间: 2015/5/29 8:15:20
    /// 描述说明：
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class ConverToHtmlEncode<T> where T : new()
    {
        /// <summary>
        ///  List Entity HTML输出的转换
        /// </summary>
        /// <param name="modelList"></param>
        /// <returns></returns>
        public static List<T> ConverToHTMLEncodeMethod(List<T> modelList)
        {

            if (modelList != null)
            {
                foreach (var x in modelList)
                {
                    Type z = x.GetType();
                    PropertyInfo[] propertyInfos = z.GetProperties();
                    foreach (PropertyInfo pi in propertyInfos)
                    {
                        if (pi.PropertyType.Name == "String")
                        {
                            string x1Value = StringHander.PageValid.HtmlEncode(Convert.ToString(pi.GetValue(x, null)));
                            //HttpContext.Current.Server.HtmlEncode(Convert.ToString(pi.GetValue(x, null)));
                            pi.SetValue(x, x1Value, null);
                        }
                    }
                }
                return modelList;
            }
            else
            {

                return null;
            }
        }


    }
}
